<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags" %>
<%--
  User: Liutong
  Date: 11/1/15
  Time: 1:14 AM
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<ul id="side-nav" class="side-nav nav">
    <%--<li class="side-nav-group sidebar-minimalizer">--%>
        <%--<span class="name">收起</span>--%>
    <%--</li>--%>
    <c:forEach items="${requestScope.MENULIST}" var="menu">

        <c:set var="str" value="${'ROLE_'}${menu.role}"></c:set>
        <%--<c:out value="${str}"/>--%>
        <sec:authorize  access="hasRole('${str}')">
            <c:choose>
                <%--包含二级菜单--%>
                <c:when test="${menu.menus != null && fn:length(menu.menus) > 0}">
                    <li <c:if test="${activeMenus[menu.code]!=null}"> class="active"</c:if>>
                        <a href="#">
                            <i class="fa ${menu.icon}"></i>
                            <span class="name"><s:message code="menu.${menu.code}" text="${menu.code}"/></span>
                            <span class="fa expand"></span>
                        </a>
                        <ul class="nav nav-second-level collapse">
                            <c:forEach items="${menu.menus}" var="subMenu">
                                <sec:authorize access="hasRole('${subMenu.role}') and fullyAuthenticated">
                                    <li <c:if test="${activeMenus[subMenu.code]!=null}"> class="active"</c:if>>
                                        <a href="<c:url value="${subMenu.url}" />">
                                            <i class="fa <c:if test="${activeMenus[subMenu.code]!=null}"> fa-caret-right</c:if>"></i>
                                            <s:message code="menu.${subMenu.code}" text="${menu.code}"></s:message>
                                        </a>
                                    </li>
                                </sec:authorize>
                            </c:forEach>
                        </ul>
                    </li>
                </c:when>
                <%--无二级菜单--%>
                <c:otherwise>
                    <li <c:if test="${activeMenus[menu.code]!=null}"> class="active"</c:if>>
                        <a href="<c:url value="${menu.url}" />">
                                <%--<span class="glyphicon ${menu.icon}"></span>--%>
                            <i class="fa ${menu.icon}"></i>
                            <span class="name"><s:message code="menu.${menu.code}" text="${menu.code}"/></span>

                                <%--<s:message code="menu.${menu.code}" text="${menu.code}"/>--%>
                        </a>
                    </li>
                </c:otherwise>
            </c:choose>
        </sec:authorize>
    </c:forEach>
</ul>